package com.ffms.servlet;


import com.ffms.dao.impl.MoneyDaoImpl;

import com.ffms.entity.Money;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/PreUpdateMoneyServlet")
public class PreUpdateMoneyServlet extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        String flag = req.getParameter("flag");
        MoneyDaoImpl moneyDaoImpl = new MoneyDaoImpl();
        Money money = moneyDaoImpl.getById(Integer.parseInt(id));
        req.setAttribute("money", money);
        req.setAttribute("flag", flag);
        req.getRequestDispatcher("/admin/moneyUpdate.jsp?flag=" + flag).forward(req, resp);

    }
}
